



<template>
  <div>
    <business @handleParam="handleParam" @handleFlge="handleFlge" />
  </div>

  <div style="display: flex;">
    <div style="width: 100%;">
      <home v-model:value="val" @handleFlge="handleFlge" />
    </div>
    <!-- 预览 -->
    <!-- <div style="width: 50%;">
    <h2 style="text-align: center;">预览</h2>
    <div v-html="val"></div>
   </div> -->
  </div>
  <button class="submit" @click="submit">提交</button>
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import home from "./components/home.vue";
import business from "./components/business.vue";
import axios from 'axios'
const val = ref('')
const flge = ref('')
const Param: any = ref()
const Param2: any = ref()
watch(val, async (newName, oldName) => {
  console.log(newName);
  if (flge.value == '1') {
    Param.value.addRehabilitationDetailReq.content = newName
  } else {
    Param2.value.addRehabilitationDetailTemplateReq.content = newName
  }
});
const handleParam = (e: any, value2: any) => {
  Param.value = e
  console.log(e);
  console.log(value2);
  flge.value = value2


}
const handleFlge = (e: any, value2: any) => {
  console.log(e);
  Param2.value = e
  flge.value = value2
  console.log(value2);

}
const submit = () => {
  if (flge.value == '1') {
    axios.post(`https://wx.futuredh.net/frontend/knee/v1/api/rehabilitation/uploadDetail`, Param.value).then((res: any) => {
      console.log(res)
      if (res.data.data === '上传成功') {
        alert('上传成功')
      }
    })
  } else {
    axios.post(`https://wx.futuredh.net/frontend/knee/v1/api/rehabilitation/uploadTemplate`, Param2.value).then((res: any) => {
      console.log(res)
      if (res.data.data === '上传成功') {
        alert('上传成功')
      }
    })

  }


}

</script>
<style scoped>
p {
  margin: 0;
  padding: 0;
}

.submit {
  width: 300px;
  color: #fff;
  background: #000;
  margin: 50px 0;
}
</style>

